﻿@using Mulala.Cavan.Presentation.Seedwork
@using Mulala.Cavan.Domain.MainBoundedContext.DictionaryModule
@model Mulala.Cavan.Presentation.Mvc.ViewModel.IConsignViewModel
@{
    ViewBag.Title = "publishconsign";
    Layout = "~/Views/Shared/_ProprietorCenterLayout.cshtml";
}
@using (Html.BeginForm())
{
    <div>
        @Html.ValidationSummary()
        <fieldset>
            <ol>
                <li>
                    @Html.LabelFor(m => m.Item.Name)
                    @Html.TextBoxFor(m => m.Item.Name, new { id = "Name" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Type)
                    @Html.DropDownListFor(m => m.TypeForEdit, DictionaryIdentifier.GroupType.ConsignType, new { id = "Type" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Age)
                    @Html.DropDownListFor(m => m.Item.Age, DictionaryIdentifier.GroupType.ConsignAgeNeed, new { id = "Age" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Sex)
                    @Html.DropDownListFor(m => m.Item.Sex, DictionaryIdentifier.GroupType.ConsignSexNeed, new { id = "Sex" })
                </li>
                <li>地区：
                    @Html.Action("selectarea", "area")
                    @Html.HiddenFor(m => m.Item.Area.ID, new { id = "Area" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Address)
                    @Html.TextBoxFor(m => m.Item.Address, new { id = "Address" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Experience)
                    @Html.DropDownListFor(m => m.Item.Experience, DictionaryIdentifier.GroupType.ConsignExperienceNeed, new { id = "Experience" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.NecessarySkill)
                    @Html.CheckBoxListFor(m => m.NeccessarySkills, DictionaryIdentifier.GroupType.NannySkill, System.Web.UI.WebControls.RepeatDirection.Horizontal)
                    @Html.HiddenFor(m => m.NeccessarySkill, new { id = "NeccessarySkill" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.IsMarried)
                    @Html.RadioButtonListFor(m => m.IsMarriedForEdit, DictionaryIdentifier.GroupType.ConsignMarriedNeed, System.Web.UI.WebControls.RepeatDirection.Horizontal)
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.HasChildren)
                    @Html.RadioButtonListFor(m => m.HasChildrenForEdit, DictionaryIdentifier.GroupType.ConsignHasChildrenNeed, System.Web.UI.WebControls.RepeatDirection.Horizontal)
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Degree)
                    @Html.DropDownListFor(m => m.Item.Degree, DictionaryIdentifier.GroupType.ConsignDegreeNeed, new { id = "Degree" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Salary)
                    @Html.DropDownListFor(m => m.Item.Salary, DictionaryIdentifier.GroupType.ConsignSalaryProvide, new { id = "Salary" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Telephone)
                    @Html.TextBoxFor(m => m.Item.Telephone, new { id = "Telephone" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Contact)
                    @Html.TextBoxFor(m => m.Item.Contact, new { id = "Contact" })
                </li>
                <li>
                    @Html.LabelFor(m => m.Item.Remark)
                    @Html.TextAreaFor(m => m.Item.Remark, new { id = "Remark" })
                </li>
            </ol>
            <input type="submit" value="保存" id="submit" />
        </fieldset>
    </div>
}
@Scripts.Render("~/bundles/jqueryui")
@Scripts.Render("~/bundles/jqueryval")
@Scripts.Render("~/bundles/edit")
<script type="text/javascript">
    $(function () {
        $("form[action$='保存']").submit(function () {

            $.post($(this).attr("action"), $(this).serialize(), function (response) {
                alert(response.Messages[0]);
            });

            return false;
        });

        $("input[name='NeccessarySkills']").click(function () {
            var neccessarySkill = "";
            $("input[name='NeccessarySkills']").each(function () {
                if ($(this).attr("checked") == "checked") {
                    neccessarySkill = neccessarySkill + $(this).val() + ',';
                }
            })
            $("#NeccessarySkill").val(neccessarySkill);
        });

        $("#Birthday").datepicker($.datepicker.regional["cn"]);
    })
</script>
